#include "../wxsitemresdata.h"
#include "wxsrichtextformattingdialog.h"
#include <wx/richtext/richtextformatdlg.h>


namespace {
  wxsRegisterItem<wxsRichTextFormattingDialog> Reg( _T( "RichTextFormattingDialog" ), _T( "RichTextFormattingDialog" ), wxsTTool, _T( "对话框" ), 90, false );
  static const long arrPageValues[] = {
    wxRICHTEXT_FORMAT_BULLETS,
    wxRICHTEXT_FORMAT_FONT,
    wxRICHTEXT_FORMAT_HELP_BUTTON,
    wxRICHTEXT_FORMAT_INDENTS_SPACING,
    wxRICHTEXT_FORMAT_LIST_STYLE,
    wxRICHTEXT_FORMAT_STYLE_EDITOR,
    wxRICHTEXT_FORMAT_TABS
  };

  static const wxChar* arrPageValueNames[] = {
    _T( "wxRICHTEXT_FORMAT_BULLETS" ),
    _T( "wxRICHTEXT_FORMAT_FONT" ),
    _T( "wxRICHTEXT_FORMAT_HELP_BUTTON" ),
    _T( "wxRICHTEXT_FORMAT_INDENTS_SPACING" ),
    _T( "wxRICHTEXT_FORMAT_LIST_STYLE" ),
    _T( "wxRICHTEXT_FORMAT_STYLE_EDITOR" ),
    _T( "wxRICHTEXT_FORMAT_TABS" ),
    NULL
  };
}

wxsRichTextFormattingDialog::wxsRichTextFormattingDialog( wxsItemResData *Data ):
  wxsTool( Data, &Reg.Info, NULL, NULL, ( flVariable | flId | flSubclass | flExtraCode ) ),
  m_sTitle( _T( "Formatting" ) ),
  m_iFlags( wxRICHTEXT_FORMAT_FONT | wxRICHTEXT_FORMAT_TABS | wxRICHTEXT_FORMAT_BULLETS | wxRICHTEXT_FORMAT_INDENTS_SPACING ) {
}


void wxsRichTextFormattingDialog::OnBuildCreatingCode() {
  wxString sFlags;
  switch( GetLanguage() ) {
  case wxsCPP:
    AddHeader( _T( "<wx/richtext/richtextformatdlg.h>" ), GetInfo().ClassName, 0 );
    for( int i = 0; arrPageValueNames[i]; i++ ) {
      if( ( m_iFlags & arrPageValues[i] ) == arrPageValues[i] ) {
        sFlags << arrPageValueNames[i] << _T( "|" );
      }
    }
    if( sFlags.IsEmpty() ) {
      sFlags = _T( "0" );
    } else
    { sFlags.RemoveLast(); }
    Codef( _T( "%C(%s, %W, %t, %I, %P, %S);\n" ), sFlags.wx_str(), m_sTitle.wx_str() );
    BuildSetupWindowCode();
    break;
  case wxsUnknownLanguage:
  default:
    wxsCodeMarks::Unknown( _T( "wxsRichTextFormattingDialog::OnBuildCreatingCode" ), GetLanguage() );
  }
}

void wxsRichTextFormattingDialog::OnEnumToolProperties( M_Code_unused long Flags ) {
  WXS_FLAGS( wxsRichTextFormattingDialog, m_iFlags, _T( "Page Flags" ), _T( "page_flags" ), arrPageValues, arrPageValueNames,
             wxRICHTEXT_FORMAT_FONT | wxRICHTEXT_FORMAT_TABS | wxRICHTEXT_FORMAT_BULLETS | wxRICHTEXT_FORMAT_INDENTS_SPACING )
  WXS_SHORT_STRING( wxsRichTextFormattingDialog, m_sTitle, _T( "Title" ), _T( "title" ), _T( "Formatting" ), true );
}
